#include <stdio.h>
#include <values.h>
#include <assert.h>
+#include "config.h"
+#include "babl-internal.h"
#include "babl.h"
#include "babl-memory.h"
#define HASH_TABLE_SIZE 1111
-void babl_sanity (void);
-
/* A default palette, containing standard ANSI / EGA colors
*
*/
return samples;
}
+int
+babl_format_is_palette (const Babl *format)
+{
+ if (format->class_type == BABL_FORMAT)
+ return format->format.palette;
+ return 0;
+}
+
/* should return the BablModel, permitting to fetch
* other formats out of it?
*/
{
const Babl *model;
const Babl *model_no_alpha;
- const Babl *f_pal_u8;
- const Babl *f_pal_a_u8;
+ Babl *f_pal_u8;
+ Babl *f_pal_a_u8;
const Babl *component;
const Babl *alpha;
BablPalette **palptr;
cname[0] = 'v';
model_no_alpha = babl_model_new ("name", name, component, NULL);
cname[0] = 'x';
- f_pal_a_u8 = babl_format_new ("name", name, model,
+ f_pal_a_u8 = (void*) babl_format_new ("name", name, model,
babl_type ("u8"),
component, alpha, NULL);
cname[0] = 'y';
- f_pal_u8 = babl_format_new ("name", name, model_no_alpha,
+ f_pal_u8 = (void*) babl_format_new ("name", name, model_no_alpha,
babl_type ("u8"),
component, NULL);
+ f_pal_a_u8->format.palette = 1;
+ f_pal_u8->format.palette = 1;
+
babl_conversion_new (
model,
babl_model ("RGBA"),
const Babl **format_u8,
const Babl **format_u8_with_alpha);
+/**
+ * check whether a format is a palette backed format.
+ */
+int babl_format_is_palette (const Babl *format);
+
/**
* Assign a palette to a palette format, the data is a single span of pixels
* representing the colors of the palette.
int count);
/**
- * reset a palette to initial state.
+ * reset a palette to initial state, frees up some caches that optimize
+ * conversions.
*/
void babl_palette_reset (const Babl *babl);
+
/**
* associate a data pointer with a format/model, this data can be accessed and
* used from the conversion functions, encoding color profiles, palettes or
- * similar with the data.
+ * similar with the data, perhaps this should be made internal API, not
+ * accesible at all from
*/
void babl_set_user_data (const Babl *babl, void *data);